/*
 * @Descripttion: 
 * @version: 
 * @Author: chenbolin@msn.cn
 * @Date: 2021-05-27 16:08:03
 * @LastEditors: chenbolin@msn.cn
 * @LastEditTime: 2023-10-10 14:48:30
 */
#include "Hal.h"


//redirect "printf()"
int fputc(int ch, FILE *f)
{
//    uint8_t data = (uint8_t)ch;
    // HalUartWrite(HAL_LOG_PORT, &data, 1);
	return ch;
}

int HalGetUUID(uint8_t *idBuff)
{
    uint32_t uid[3];

    uid[0] = HAL_GetUIDw0();
    uid[1] = HAL_GetUIDw1();
    uid[2] = HAL_GetUIDw2();

    memcpy(idBuff, (uint8_t *)uid, sizeof(uid));
    return sizeof(uid);
}

uint32_t HalGetTicks(void)
{
    return HAL_GetTick();
}

void HalInterruptSet(bool enable)
{
    if(enable)
    {
        __enable_irq();
    }
    else
    {
        __disable_irq(); 
    }
}

void HalReboot(void)
{
    __set_FAULTMASK(1); 
    NVIC_SystemReset();
}

void HalWaitMs(uint32_t ms)
{
    HAL_Delay(ms);
}

// static void startupInit(void)
// {
//     HalUartConfig_t config;
    
//     config.baudrate = 115200;
//     config.recvCb = NULL;
//     HalUartConfig(HAL_LOG_PORT, &config);
// }

void HalInitialize(void)
{  
    HalGPIOInitialize();
    HalUartInitialize();
    HalPWMInitialize();
    HalDACInitialize();
    // startupInit();
}

void HalPoll(void)
{
}

